
<div class="col-lg-12" id="container-button-save">
    <div id="main_button" class="btn btn-danger">Lưu Dữ Liệu</div>
    <h1 class="page-header">Danh mục sản phẩm</h1>
    
</div>
<br/>

<div class="col-lg-12">
    

    <ul id="myTab" class="nav nav-tabs">
        <li class="active"><a href="#home" class="h_item_tab" >Thông tin chung</a></li>

    </ul>
    <div id="myTabContent" class="tab-content h_tab_content well">
        <?php
        $form = $this->beginWidget('booster.widgets.TbActiveForm', array('htmlOptions' => array('id' => 'h_main_form', 'enctype' => 'multipart/form-data')));
        ?>
        <div class="tab-pane active" id="home">
            <p>

                <?php
                echo $form->textFieldGroup($model, 'name');
                echo $form->dropDownListGroup(
                        $model, 'parents', array(
                            'widgetOptions' => array(
                                'data' => $listMenu,
                            )
                        )
                );
                echo $form->textFieldGroup($model, 'orders');
                echo $form->dropDownListGroup(
                        $model, 'typeMenu', array(
                            'widgetOptions' => array(
                                'data' => getMenuType(),
                            )
                        )
                );
                echo $form->textFieldGroup($model, 'search');
                echo $form->textFieldGroup($model, 'link');
                ?>
                
            </p>
        </div>
        
        <?php
        $this->endWidget();
        unset($form);
        ?>
        

    </div>


</div>
<script>
    $(document).ready(function(){
        /**
         * 
         */
        $('#Menu_search').typeahead({
            onSelect: function(item) {
                $("#Menu_link").val(item.value);
            },
            ajax: {
                url: "<?php echo Yii::app()->createurl('menu/search');?>",
                timeout: 500,
                displayField: 'name',
                triggerLength: 1,
                method: "post",
                loadingClass: "loading-circle",
                preDispatch: function (query) {
                    return {
                        search: query,
                        type: $("#Menu_typeMenu").val()
                    }
                },
                preProcess: function (data) {
                    console.log(data);
                    return data;
                }
             }
       });
       
       /**
       * 
       */
       function executeChangeType(){
            if($('#Menu_typeMenu').val() == 0){
                $('#Menu_search').parents('.form-group').hide();
            }else{
                $('#Menu_search').parents('.form-group').show();
            } 
       }
       executeChangeType();
       $('#Menu_typeMenu').on('change',function(){
           executeChangeType();
       });

    });
</script>